/*
 * @Author: 迷洛洛ywc
 * @Date: 2024-05-30 14:44:56
 * @LastEditors: 迷洛洛ywc
 * @LastEditTime: 2024-06-20 14:57:11
 * @Description: file content
 */
import Vue from 'vue'
import VueRouter from 'vue-router'
// import wx from 'weixin-js-sdk'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'index',
    redirect: '/productRecord',
    component: () => import('../views/index'),
    meta: {
      title: '查看溯源'
    },
    children: [
      // {
      //   path: '/index',
      //   component: () => import('../views/index'),
      //   name: '首页'
      // },
      {
        path: '/baseInfo',
        name: 'baseInfo',
        component: () => import('../views/baseInfo')
      },
      {
        path: '/growthRecord',
        name: 'growthRecord',
        component: () => import('../views/growthRecord'),
        meta: {
          title: '产品信息'
        }
      },
      {
        path: '/productRecord',
        name: 'productRecord',
        component: () => import('../views/productRecord'),
        meta: {
          title: '农事记录'
        }
      },
      {
        path: '/testing',
        name: 'testing',
        component: () => import('../views/testing'),
        meta: {
          title: '权威监测'
        }
      },
      {
        path: '/investment',
        name: 'investment',
        component: () => import('../views/investment'),
        meta: {
          title: '农资投入'
        }
      },
      {
        path: '/situation',
        name: 'situation',
        component: () => import('../views/situation'),
        meta: {
          title: '农情记录'
        }
      }
    ]
  },
  {
    path: '/edit',
    name: 'edit',
    component: () => import('../views/edit'),
    meta: {
      title: '溯源编辑'
    }
  },
  {
    path: '/report',
    name: 'report',
    component: () => import('../views/report'),
    meta: {
      title: '检测报告'
    }
  },
  {
    path: '/missionDetail',
    name: 'missionDetail',
    component: () => import('../views/missionDetail'),
    meta: {
      title: '农事详情'
    }
  },
  {
    path: '/addLand',
    name: 'addLand',
    component: () => import('../views/addLand'),
    meta: {
      title: '添加地块'
    }
  },
  {
    path: '/addLandCopy',
    name: 'addLandCopy',
    component: () => import('../views/addLandCopy'),
    meta: {
      title: '我的地块'
    }
  },
  {
    path: '/addLandSelect',
    name: 'addLandSelect',
    component: () => import('../views/addLandSelect'),
    meta: {
      title: '我的地块'
    }
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
// 全局前置路由守卫————初始化的时候被调用、每次路由切换之前被调用
// router.beforeEach((to, from, next) => {
//   // 在全局导航守卫中触发 wx.miniProgram.navigateBack({})
//   console.log('1')
//   wx.miniProgram.navigateBack({})
//   // 如果你想要阻止路由跳转，可以注释下面这行代码
//   next()
// })
export default router
